<?php
session_start();
require("../bin/common.php");
checkSess();
checkInstall();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Setup Accounts - Vanadium Patch Mananger</title>
<link href="../lib/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../lib/script.js"></script>
<script type="text/javascript">

function addAcc() {
	var total = document.getElementById('amt_total').value;
	var form = document.getElementById('accounts');
	var math = total + 1;
	
	form.innerHTML = form.innerHTML + 'Username: <input type="text" name="user_'+ total +'" style="color: #0a0a0a" /><br />';
	form.innerHTML = form.innerHTML + 'Password: <input type="text" name="pass_'+ total +'" style="color: #0a0a0a" /><br /><br />';
	
	document.getElementById('amt_total').value = parseInt(total) + 1;
}
</script>
</head>
<body onload="fixSize()" onresize="fixSize()">

<div class="container" id="container">

	<!-- Header -->
	<div class="top">
	Vanadium Patch Manager

	<?php
	dispLogin();
	?>
	</div>
    
	<!-- Left Hand Panel -->
	<div class="left">
		<br /><span class="nav_option"><img src="../lib/gfx/icon_home.gif" width="15" height="15" alt="Home" /> <a href="../home/">Home</a></span><br /><br />
		<span class="nav_tab_option"><img src="../lib/gfx/icon_add.gif" width="12" height="12" alt="Add" /> <a href="../addpatch/">Add Patch</a></span><br /><br />
		<span class="nav_tab_option"><img src="../lib/gfx/icon_edit.gif" width="13" height="16" alt="Edit" /> <a href="../patch/changelog.php">View Changelog</a></span><br /><br />
		<span class="nav_tab_option"><img src="../lib/gfx/icon_edit.gif" width="13" height="16" alt="Edit" /> <a href="../editpatch/">Edit Patch Home</a></span><br /><br />
		<span class="nav_tab_option"><img src="../lib/gfx/icon_setup.gif" width="14" height="16" alt="Setup" /> <a href="../setup/">Setup</a></span><br /><br />
        <span class="nav_tab_tab_option"><img src="../lib/gfx/icon_edit.gif" width="13" height="16" alt="Edit" /> <a href="../setup/neoncube.php">Neoncube.ini</a></span><br /><br />
        <span class="nav_tab_tab_option"><img src="../lib/gfx/icon_account.gif" width="14" height="14" alt="Accounts" /> <a href="../setup/accounts.php">Accounts</a></span><br /><br />
        <span class="nav_tab_tab_option"><img src="../lib/gfx/icon_cp.gif" width="16" height="16" alt="Control Panel" /> <a href="../setup/cpanel.php">Control Panel</a></span>
	</div>
    
	<!-- Body Content Container -->
	<div class="content_container" id="content_container">
    
		<!--Content Title -->
		<div class="content_title">
			Setup - Accounts
		</div>
        
		<!--Content Body -->
		<div class="content_body">
        	Here you are able to add/modify/remove users from the accounts list. When you are satisfied with the modifications, please press the submit buttom. The values which appear here will be the ones which will appear in your accounts file, so please do not remove all of them (will cause issues).<br /><br />
            
            <form method="post" action="modifyacc.php">
            <font style="font-size: 16px"><b>Current Accounts:</b></font><br /><br />
            <?php
			
			//Load Accounts
			$loadacc = file_get_contents("../lib/accounts.php") or exit("Cannot open accounts.php");
			
			//Remove PHP Tags
			$rem_tag = substr($loadacc,6,-3);
			
			//Define user/pass relationships
			$rem_tag = str_replace("\n","&&",$rem_tag);
			
			//Remove # from start of each line
			$rem_tag = str_replace("#","",$rem_tag);
			
			//Split into it's combinations.
			$acc_arr = explode("&&",$rem_tag);
			
			//Split into it's user/pass
			for ($count = 0; $count < count($acc_arr); $count++) {
				$acc_comb[$count] = explode("||",$acc_arr[$count]);
			}
			
			//Display Accounts
			$correct = 0;
			for ($count = 0; $count < count($acc_comb); $count++) {
				
				echo "Username: <input type=\"text\" name=\"user_".$count."\" style=\"color: #0a0a0a\" value=\"".$acc_comb[$count][0]."\" /><br />";
				echo "Password: <input type=\"text\" name=\"pass_".$count."\" style=\"color: #0a0a0a\" value=\"".$acc_comb[$count][1]."\" /><br /><br />";
			}
			
			echo "<input type=\"hidden\" id=\"amt_total\" name=\"amt_total\" value=\"".count($acc_comb)."\" />";
			
			?>
            <span id="accounts"></span>
            <img src="../lib/gfx/icon_add_in.gif" width="12" height="12" alt="Add" /> <a onclick="addAcc();">Add Another Account</a><br />
            <br /><input type="submit" value="Modify Accounts" style="color: #0a0a0a" />
          </form>
            
	  </div>
	<!--End Content Container-->
	</div>
    
	<!--Footer -->
	<div class="footer">
		Vanadium Patch Manager, A Neoncube Patch Modification.<br />
		GNU General Public License v3 - 2010<br />
		http://code.google.com/p/vanadiumpatch/
	</div>

<!--End Container-->
</div>
</body>
</html>